﻿using KouDai.Core.Models;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace KouDai.Metro.Controls
{
    public class VariableGridView : GridView
    {
        private int iLoop = 0;

        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            var rItem = (RatioImage)item;

            var rowspans = new[] { 2, 2, 2, 2, 2, 2, 2, 4, 4, 2 };
            var colspans = new[] { 2, 3, 2, 2, 2, 3, 2, 2, 1, 2 };

            if (iLoop < 10)
            {
                element.SetValue(VariableSizedWrapGrid.ColumnSpanProperty, colspans[iLoop]);
                element.SetValue(VariableSizedWrapGrid.RowSpanProperty, rowspans[iLoop]);
                iLoop++;
            }
            else
            {
                iLoop = 0;
            }
            base.PrepareContainerForItemOverride(element, item);
        }
    }
}
